#include <iostream>
#include <cstdint>
using namespace std;

/**
 * @brief 32bit reverse output 
 * 
 */
class Solution
{
public:
    uint32_t reverseBits(uint32_t n)
    {
        unsigned long int mask = 0;
        for (int i = 0; i <= 31; i++)
        {
            if (n & 1 == 1)
            {
                mask |= 1;
            }
            mask <<= 1;
            n >>= 1;
        }
        return mask >> 1;
    }

    uint32_t reverseBits_2(uint32_t n)
    {
        uint32_t ans = 0;
        for (int i = 0; i < 32; i++)
        {
            ans |= ((n & 1) << (31 - i));
            n >>= 1;
        }

        return ans;
    }
};

int main(int argc, char const *argv[])
{
    Solution s;
    /**
     * @brief  test set
     * 964176192 --> 0b00000010100101000001111010011100
     */
    uint32_t res = s.reverseBits(0b00000010100101000001111010011100);
    cout << res << endl;
     return 0;
}
